package com.htlh.notificationdemo;

import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Intent;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.app.NotificationCompat;
import android.view.View;
import android.widget.Button;

public class MainActivity extends AppCompatActivity {

    private android.widget.Button btnnotification;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        this.btnnotification = (Button) findViewById(R.id.btn_notification);

        btnnotification.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MainActivity.this, NotificationActivity.class);
                PendingIntent pendingIntent = PendingIntent.getActivity(MainActivity.this, 0, intent, 0);

                NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
                Notification notification = new NotificationCompat.Builder(MainActivity.this)
                        .setContentTitle("this is content title")
                        .setContentText("this is content text")
                        .setWhen(System.currentTimeMillis())
                        .setSmallIcon(R.mipmap.ic_launcher_round)
                        .setLargeIcon(BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher))
                        .setContentIntent(pendingIntent)
//                        .setAutoCancel(true)
//                        .setVibrate(new long[]{0,1000,1000,1000})
//                        .setLights(Color.RED,1000,1000)
//                        .setDefaults(NotificationCompat.DEFAULT_ALL)
                        .setContentText("setVibrate(new long[]{0,1000,1000,1000}setVibrate(new long[]{0,1000,1000,1000}setVibrate(new long[]{0,1000,1000,1000}setVibrate(new long[]{0,1000,1000,1000}setVibrate(new long[]{0,1000,1000,1000}")
                        .build();
                manager.notify(1,notification);
            }
        });
    }
}
